package com.market.pay.details;

import com.market.entity.base.Fruit;
import com.market.entity.dto.OrderDto;
import com.market.pay.base.PricingStrategy;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public class BasePricingStrategy implements PricingStrategy {
    @Override
    public BigDecimal calculateTotal(OrderDto orderDto) {
        BigDecimal total = BigDecimal.ZERO;
        for (Map.Entry<Fruit, BigDecimal> entry : orderDto.getItems().entrySet()) {
            Fruit fruit = entry.getKey();
            BigDecimal weight = entry.getValue();
            total= total.add(fruit.getFruitPrice().multiply(weight));
        }
        return total;
    }
}
